<div class="max-w-lg mx-auto px-2">
  <h1 class="text-3xl font-bold text-center mt-8">Profile Details</h1>
  <%= form_for('', as: resource_name, html: { class: 'space-y-6' }, data: { turbo: params[:redir].blank? }, url: new_registration_path) do |f| %>
    <% if params[:redir].present? %>
      <%= hidden_field_tag :redir, params[:redir] %>
    <% end %>
    <div class="space-y-2">
      <%= render 'devise/shared/error_messages', resource: %>
      <%= f.fields_for resource do |ff| %>
        <div class="grid gap-2 md:grid-cols-2 md:gap-4">
          <div class="form-control">
            <%= ff.label :first_name, class: 'label' %>
            <%= ff.text_field :first_name, required: true, class: 'base-input' %>
          </div>
          <div class="form-control">
            <%= ff.label :last_name, class: 'label' %>
            <%= ff.text_field :last_name, required: true, class: 'base-input' %>
          </div>
        </div>
      <% end %>
      <%= f.fields_for resource do |ff| %>
        <div class="form-control <%= 'hidden' if (params[:oauth_callback] || params[:sign_up]) && resource.email? %>">
          <%= ff.label :email, class: 'label' %>
          <%= ff.email_field :email, value: EmailTypo.call(resource.email), required: true, class: 'base-input' %>
        </div>
      <% end %>
      <%= f.fields_for resource.account do |ff| %>
        <set-timezone data-input-id="_account_timezone"></set-timezone>
        <%= ff.hidden_field :timezone %>
        <div class="form-control">
          <%= ff.label :name, 'Company name (optional)', class: 'label' %>
          <%= ff.text_field :name, class: 'base-input' %>
        </div>
      <% end %>
      <%= f.fields_for resource do |ff| %>
        <div class="form-control <%= 'hidden' if params[:oauth_callback] %>">
          <%= ff.label :password, class: 'label' %>
          <%= ff.password_field :password, required: !params[:oauth_callback], class: 'base-input' %>
        </div>
      <% end %>
    </div>
    <div class="form-control">
      <%= f.button button_title(title: 'Sign up', disabled_with: 'Signing up'), class: 'base-button' %>
    </div>
  <% end %>
  <%= render 'devise/shared/links' %>
</div>
